#ifndef __APP_SERIAL_H__
#define __APP_SERIAL_H__
#include "app/app_device.h"
#include <termios.h>


typedef enum{
   SERIAL_BUAD_RATE_9600 = '4',
   SERIAL_BUAD_RATE_115200 = '8'
} SerialBaudRate;

typedef enum {
   STOP_BITS_ONE = 0,
   STOP_BITS_TWO = CSTOPB,
} StopBits;

typedef enum {
   PARITY_NONE = 0,
   PARITY_ODD = PARENB | PARODD,
   PARITY_EVEN = PARENB, 
} Parity;

typedef struct SerialDeviceStruct{
   Device super; 
   SerialBaudRate baud_rate;
   StopBits stop_bits;
   Parity parity;
} SerialDevice;

int app_serial_init(SerialDevice *serial_device, char *filename);

int app_serial_setBaudRate(SerialDevice *serial_device, SerialBaudRate baud_rate);
int app_serial_setStopBits(SerialDevice *serial_device, StopBits stop_bits);
int app_serial_setParity(SerialDevice *serial_device, Parity parity);
int app_serial_flush(SerialDevice * serial_device);

int app_serial_setBlockMode(SerialDevice *serial_device, int block_mode);

#endif